﻿using GetSlaughterItem.API.Application.Commands.Week02.Scale;
using GetSlaughterItem.API.Application.Commands.Week02.SetupCommand;
using GetSlaughterItem.API.Application.Commands.Week02.SlaughterCommands;
using GetSlaughterItem.API.Application.Commands.Week03.Reports;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SlaughterItem.Common.Dtos;

namespace GetSlaughterItem.API.Controllers.SuYi
{
    /// <summary>
    /// 第二周任务 待宰圈 折扣项 副产品称重显示
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class Week2GetController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<Week2GetController> logger;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public Week2GetController(IMediator mediator, ILogger<Week2GetController> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 待宰圈设置显示查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> QueryWaiting(WaitingQueryCommand cmd)
        {
            try
            {
                logger.LogInformation("待宰圈设置显示查询");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("待宰圈设置显示查询失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 扣减项设置显示查询
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> QueryDeductions(DeductionsQueryCommand cmd)
        {
            try
            {
                logger.LogInformation("扣减项设置显示查询");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("扣减项设置显示查询失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 批宰根据日期统计显示
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> TimeGroupPlan(TimeGroupPlanCommand cmd)
        {
            try
            {
                logger.LogInformation("批宰根据日期统计显示");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("批宰根据日期统计显示失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 根据选中的时间进行查询当天的所有数据
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> SlaughterEveryDayGroup(SlaughterEveryDayGroupCommand cmd)
        {
            try
            {
                logger.LogInformation("根据选中的时间进行查询当天的所有数据");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("根据选中的时间进行查询当天的所有失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 根据仓库查询磅秤绑定下拉框
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> ScaleShow(ScaleShowCommand cmd)
        {
            try
            {
                logger.LogInformation("根据仓库查询磅秤");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("根据仓库查询磅秤失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 查询仓库绑定下拉框
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> WarehouseDataShow(WarehouseDataShowCommand cmd)
        {
            try
            {
                logger.LogInformation("查询仓库绑定下拉框");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("查询仓库绑定下拉框失败" + ex.Message);

                throw;
            }
        }
        /// <summary>
        /// 副宰显示前6条信息
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> WeighingSheetsShow(WeighingSheetsShowCommand cmd)
        {
            try
            {
                logger.LogInformation("副宰显示前6条信息");
                return await mediator.Send(cmd);
            }
            catch (Exception ex)
            {
                logger.LogError("副宰显示前6条信息" + ex.Message);

                throw;
            }
        }
    }
}
